package com.scs.application.core.consts;

import com.scs.application.core.entity.DataEntity;
import com.scs.application.core.entity.FlowEntity;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Const {
    /*各种路径定义*/
    // 以文件形式存储的程序设计源文件路径
    public static String FILE_STORE_SRC = System.getProperty("user.dir") + "/src/main/resources/static/file-store/";
    public static String MENU_FILE_SRC = FILE_STORE_SRC + getMenuFileSrc();
    public static String INIT_DATA_SQL_SRC = FILE_STORE_SRC + getInitDataSqlSrc();
    public static String DATA_VIEW_DTL_SRC = FILE_STORE_SRC + getDataViewDtlSrc();
    public static String DATA_VIEW_DICT_SRC = FILE_STORE_SRC + getDictSrc();
    public static String PRINT_TEMP_SRC = FILE_STORE_SRC + getPrintTempSrc();
    public static String DATA_VIEW_FLOW_SRC = FILE_STORE_SRC + getFlowSrc();
    public static String DATA_VIEW_PARAMETER_SRC = FILE_STORE_SRC + getParamSrc();
    public static String DATA_VIEW_SERIAL_RULE_SRC = FILE_STORE_SRC + getSerialRuleSrc();

    public static String INIT_DATE_SRC = FILE_STORE_SRC + "init-data/";

    public static String ICONFONT_SRC = FILE_STORE_SRC + "iconfont.json";

    // 自动代码存放路径
    public static String AUTO_CODE_PATH = "D:\\_build_file\\";


    public static String getInitDataSqlSrc() {
       return "init-data-sql.json";
    }

    public static String getMenuFileSrc(){
        return "menu.json";
    }

    public static String getDataViewDtlSrc(){
        return "dv-dtl/";
    }

    public static String getDictSrc(){
        return "dict/";
    }
    public static String getPrintTempSrc(){
        return "print-temp/";
    }

    public static String getFlowSrc(){
        return "flow/";
    }

    public static String getParamSrc(){
        return "parameter/";
    }

    public static String getSerialRuleSrc(){
        return "serial-rule/";
    }

    public static String getIconFontSrc() {
        return "iconfont.json";
    }
    //FlowEntity 和 DataEntity对象的属性列表
    public static String[] FIELDS_FLOW_ENTITY_AND_DATA_ENTITY = null;
    static {
        //初始化  FIELDS_FLOW_ENTITY_AND_DATA_ENTITY
        List<String> fieldList = new ArrayList<>();
        fieldList.addAll(Arrays.stream(DataEntity.class.getDeclaredFields()).map(Field::getName).collect(Collectors.toList()));
        fieldList.addAll(Arrays.stream(FlowEntity.class.getDeclaredFields()).map(Field::getName).collect(Collectors.toList()));
        fieldList = fieldList.stream().distinct().collect(Collectors.toList());
        FIELDS_FLOW_ENTITY_AND_DATA_ENTITY = fieldList.toArray(new String[fieldList.size()]);
        fieldList = null;
    }
}
